From 47237ddd94371e0c42ad4b2d6ef25d219d78d350 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 17 Sep 2015 19:14:37 -0400 Subject: [PATCH] inspector: Add a reset button for settings This is exercising the new gtk_settings_reset_property api. https://bugzilla.gnome.org/show_bug.cgi?id=755008 --- gtk/inspector/prop-editor.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c index 3283027454..0efbfa326a 100644 --- a/gtk/inspector/prop-editor.c +++ b/gtk/inspector/prop-editor.c @@ -1534,6 +1534,13 @@ add_settings_info (GtkInspectorPropEditor *editor) gtk_container_add (GTK_CONTAINER (editor), row); } +static void +reset_setting (GtkInspectorPropEditor *editor) +{ + gtk_settings_reset_property (GTK_SETTINGS (editor->priv->object), + editor->priv->name); +} + static void add_gtk_settings_info (GtkInspectorPropEditor *editor) { @@ -1541,6 +1548,7 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor) const gchar *name; GtkWidget *row; const gchar *source; + GtkWidget *button; object = editor->priv->object; name = editor->priv->name; @@ -1551,6 +1559,14 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor) row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_container_add (GTK_CONTAINER (row), gtk_label_new (_("Source:"))); + button = gtk_button_new_with_label (_("Reset")); + g_signal_connect_swapped (button, "clicked", G_CALLBACK (reset_setting), editor); + + gtk_widget_set_halign (button, GTK_ALIGN_END); + gtk_widget_show (button); + gtk_widget_set_sensitive (button, FALSE); + gtk_box_pack_end (GTK_BOX (row), button, FALSE, FALSE, 0); + switch (_gtk_settings_get_setting_source (GTK_SETTINGS (object), name)) { case GTK_SETTINGS_SOURCE_DEFAULT: @@ -1563,6 +1579,7 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor) source = _("XSettings"); break; case GTK_SETTINGS_SOURCE_APPLICATION: + gtk_widget_set_sensitive (button, TRUE); source = _("Application"); break; default: -- 2.30.2